﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

using Microsoft.ApplicationBlocks.Updater;
using Microsoft.ApplicationBlocks.Updater.Downloaders;

using NUnit.Framework;

namespace DotUpdater.Test
{
    [TestFixture]
    public class TestDownloader
    {
        private IDownloader _downloader;

        private IDownloader Downloader
        {
            get
            {
                if (_downloader == null)
                {
                    _downloader = new BitsDownloader("", "",
                        BG_AUTH_SCHEME.BG_AUTH_SCHEME_BASIC,
                        BG_AUTH_TARGET.BG_AUTH_TARGET_SERVER);
                }
                
                return _downloader;
            }
        }

        [Test]
        public void TestDownloaderSimple()
        {
            UpdaterTask task = new UpdaterTask(
                "c:\\", "http://p-navigator.com/builds/", 
                new[] { "manifests.xml" },
                "dummy", new[] { "dummy" });

            Downloader.Download(task, TimeSpan.FromSeconds(30));

            Assert.IsTrue(File.Exists("c:\\manifests.xml"));
        }
    }
}
